using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ShivamEMR.Model.Domain.PharmacyDomain;
using ShivamEMR.Model.DataInterfaces.PharmacyDataInterf;
using ShivamEMR.Model;
//using ShivamEMR.Web.Areas.Pharmacy.Models;

namespace ShivamEMR.Web.Areas.Pharmacy.Controllers
{   
    public class DrugContraIndicationController : Controller
    {
		private readonly IDrugGenericRepository druggenericRepository;
		private readonly IDrugContraIndicationRepository drugcontraindicationRepository;

		// If you are using Dependency Injection, you can delete the following constructor
        public DrugContraIndicationController() 
        {
            druggenericRepository = Registry.RepositoryFactory.GetDrugGenericRepository();
            drugcontraindicationRepository = Registry.RepositoryFactory.GetDrugContraIndicationRepository();
        }

        public DrugContraIndicationController(IDrugGenericRepository druggenericRepository, IDrugContraIndicationRepository drugcontraindicationRepository)
        {
			this.druggenericRepository = druggenericRepository;
			this.drugcontraindicationRepository = drugcontraindicationRepository;
        }

        //
        // GET: /DrugContraIndication/

        public ViewResult Index()
        {
         //   return View(drugcontraindicationRepository.AllIncluding(drugcontraindication => drugcontraindication.DrugGeneric));
            return View(drugcontraindicationRepository.All);
        }

        //
        // GET: /DrugContraIndication/Details/5

        public ViewResult Details(System.Guid id)
        {
            return View(drugcontraindicationRepository.Find(id));
        }

        //
        // GET: /DrugContraIndication/Create

        public ActionResult Create()
        {
			ViewBag.PossibleDrugGenerics = druggenericRepository.All;
            return View();
        } 

        //
        // POST: /DrugContraIndication/Create

        [HttpPost]
        public ActionResult Create(DrugContraIndication drugcontraindication)
        {
            if (ModelState.IsValid) {
                drugcontraindicationRepository.InsertOrUpdate(drugcontraindication);
                drugcontraindicationRepository.Save();
                return RedirectToAction("Index");
            } else {
				ViewBag.PossibleDrugGenerics = druggenericRepository.All;
				return View();
			}
        }
        
        //
        // GET: /DrugContraIndication/Edit/5
 
        public ActionResult Edit(System.Guid id)
        {
			ViewBag.PossibleDrugGenerics = druggenericRepository.All;
             return View(drugcontraindicationRepository.Find(id));
        }

        //
        // POST: /DrugContraIndication/Edit/5

        [HttpPost]
        public ActionResult Edit(DrugContraIndication drugcontraindication)
        {
            if (ModelState.IsValid) {
                drugcontraindicationRepository.InsertOrUpdate(drugcontraindication);
                drugcontraindicationRepository.Save();
                return RedirectToAction("Index");
            } else {
				ViewBag.PossibleDrugGenerics = druggenericRepository.All;
				return View();
			}
        }

        //
        // GET: /DrugContraIndication/Delete/5
 
        public ActionResult Delete(System.Guid id)
        {
            return View(drugcontraindicationRepository.Find(id));
        }

        //
        // POST: /DrugContraIndication/Delete/5

        [HttpPost, ActionName("Delete")]
        public ActionResult DeleteConfirmed(System.Guid id)
        {
            var drugcontra = drugcontraindicationRepository.Find(id);
            drugcontraindicationRepository.Delete(drugcontra);
            drugcontraindicationRepository.Save();

            return RedirectToAction("Index");
        }
    }
}

